home *** CD-ROM | disk | FTP | other *** search
- Path: kuhub.cc.ukans.edu!anh
- From: anh@kuhub.cc.ukans.edu
- Newsgroups: comp.lang.c
- Subject: Re: REQUEST: Recursive functions
- Message-ID: <1996Mar26.185646.116671@kuhub.cc.ukans.edu>
- Date: 26 Mar 96 18:56:46 CST
- References: <4h7lft$8ql@cis.clark.edu> <3150334B.1802@willows.com> <4j72jhINNp77@keats.ugrad.cs.ubc.ca>
- Organization: University of Kansas Academic Computing Services
-
- Now that I think about it, yeah, you are right. I could find my way out
- but I would not necessary visit the whole maze per se, and I could also
- be wandering in circles. Oh, well,
-
- How about this one (2-minute's solution):
-
- If the maze is represented as a 2d array,
-
- Assume the walls are marked as Maze[i][j]='x'.
- The empty cells with Maze[i][j]='u'.
-
- Just 'walk' thru the maze but mark the starting position with
- Maze[starty][startx]='s', and other positions with Maze[i][j]='w' to
- indicate you have been there. At each intersection, roll the dice and
- pick a direction. You can simply backtrack along the 'w' trail when
- you run into a dead-end or into your own track, at each backtrackking step,
- check for a new possible direction. If you get back to 's' and no other
- directions possible and no cheese, then no cheese. :-)
-
- Some notes:
-
- I would just pick a direction and keep going until I cannot go further
- in the same direction. But, before I backtrack, I check to see if I can
- go in another direction.
-
- Anh
-
- In article <4j72jhINNp77@keats.ugrad.cs.ubc.ca>, c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
- > In article <1996Mar25.125041.116595@kuhub.cc.ukans.edu>,
- > <anh@kuhub.cc.ukans.edu> wrote:
-
- > False. You will visit the whole maze if it is isomorphic to a connected,
- > acyclic graph. Then, the search you describe is basically a depth-first
- > traversal.
- >
- > If the maze has cycles, you will end up not visiting some of the cells. You
- > might not even find your way out, if the starting point is in the centre, and
- > the rule of keeping to the right forces you to follow a wall that is surrounded
- > by a loop.
- > --
- >
-